package com.lightjet.macross.base.awf.enums;

import lombok.Getter;

import java.text.MessageFormat;

/** description:信息提示集合  */
@Getter
public enum AWFInfoEnum {

    /** 未知异常 */
    UNKNOWN_ERROR("AWF-0001","出错","未知异常",(byte) 0),

    /** 未知异常 */

    PROCESSSTART_ERROR("AWF-0012","流程发起失败","详情：",(byte) 0),
    PROCESSSTART_NOORIGINATOR_ERROR("AWF-0012-1","流程发起失败","发起人未设置：",(byte) 0),
    STARTNODEAUTOFINISH_ERROR("AWF-0013","发起流程节点自动处理失败","未能获取第一个节点任务",(byte) 0),
    GETFORM_ERROR("AWF-0014","获取任务表单失败","未能找到任务号：{0}相应的任务表单信息",(byte) 0),
    GETFORM_PARSE_ERROR("AWF-0014-1","获取任务表单失败","表单反序列化出错【{0}】",(byte) 0),
    GETFORM_PREVIOUS_ERROR("AWF-0014-2","获取任务表单失败","未能找到前序任务表单信息【流程ID：{0}，任务ID：{1}】",(byte) 0),
    TASKEXECUTE_ERROR("AWF-0015","处理任务【{0}】出错","详情：{1}",(byte) 0),
    TASKEXECUTE_CANDIDATE_ERROR("AWF-0015-1","处理任务出错","任务【{0}】的候选人员没有用户【{1}】",(byte) 0),
    TASKEXECUTE_ASSIGNEE_ERROR("AWF-0015-2","处理任务出错","任务【{0}】不属于用户【{1}】",(byte) 0),
    TASKEXECUTE_PROCESSING_ERROR("AWF-0015","处理任务出错","该任务正在进行服务任务处理，请勿重复提交",(byte) 0),
    GETTASK_ERROR("AWF-0016","获取任务信息失败","未能找到任务号：{0}相应的任务信息",(byte) 0),
    TASKFINISH_BIZ_ERROR("AWF-0016","流程结束出错","流程【{0}】结束回调业务逻辑出错：{1}",(byte) 0),

    TASKFIX_ASSINEENOTMATCH_ERROR("AWF-0017-1","任务修复出错","任务【{0}】的当前处理人【{1}】不是【{2}】",(byte) 0),
    TASKFIX_BIZ_ERROR("AWF-0017-2","任务修复出错","任务【{0}】的服务任务处理失败:{1}",(byte) 0),
    GETTASKASSINEE_EXPRESSION_ERROR("AWF-0018-1","获取任务处理人出错","流程【{0}】节点【{1}】表达式【{2}】解析出错，缺少@符号",(byte) 0),
    GETTASKASSINEE_HANDLEREMPTY_ERROR("AWF-0018-2","获取任务处理人出错","流程【{0}】节点【{1}】表达式【{2}】缺少处理内容",(byte) 0),
    GETTASKASSINEE_HANDLERPARSE_ERROR("AWF-0018-3","获取任务处理人出错","流程【{0}】节点【{1}】表达式【{2}】反射接口类失败：{3}",(byte) 0),
    GETTASKASSINEE_HANDLEUNKOWN_ERROR("AWF-0018-4","获取任务处理人出错","流程【{0}】节点【{1}】表达式【{2}】处理内容未知",(byte) 0),
    GETTASKASSINEE_HANDLEUNIMPLEMENTED_ERROR("AWF-0018-5","获取任务处理人出错","流程【{0}】节点【{1}】表达式【{2}】处理类未实现IAssignee接口",(byte) 0),
    GETTASKASSINEE_ASSINEEEMPTY_ERROR("AWF-0018-6","获取任务处理人出错","流程【{0}】节点【{1}】获取人员为空",(byte) 0),

    PROCESSFINISH_EXPRESSION_ERROR("AWF-0019-1","流程结束回调业务处理出错","流程【{0}】表达式【{1}】解析出错，缺少@符号",(byte) 0),
    PROCESSFINISH_HANDLEREMPTY_ERROR("AWF-0019-2","流程结束回调业务处理出错","流程【{0}】表达式【{1}】缺少处理内容",(byte) 0),
    PROCESSFINISH_HANDLERPARSE_ERROR("AWF-0019-3","流程结束回调业务处理出错","流程【{0}】表达式【{1}】反射接口类失败：{2}",(byte) 0),
    PROCESSFINISH_HANDLEUNKOWN_ERROR("AWF-0019-4","流程结束回调业务处理出错","流程【{0}】表达式【{1}】处理内容未知",(byte) 0),
    PROCESSFINISH_HANDLEUNIMPLEMENTED_ERROR("AWF-0019-5","流程结束回调业务处理出错","流程【{0}】表达式处理类【{1}】未实现IFinish接口",(byte) 0),

    TASKDELEGATE_TARGET_ERROR("AWF-0020-1","流程任务转办出错","任务【{0}】代理人为空",(byte) 0),

    JUMPTOSELF_ERROR("AWF-0030","流程跳转出错","目标接点不能为当前节点",(byte) 0),
    JUMPFINISH_ERROR("AWF-0031","流程跳转出错","目标节点监听事件处理失败",(byte) 0),

    AUTHTOKEN_NOTFOUND_ERROR("AWF-0501","访问被拒绝","请求所需的令牌未找到",(byte) 0),
    AUTHTOKEN_EXPIRE_ERROR("AWF-0502","访问被拒绝","令牌时间过期",(byte) 0),

    FORMDATA_UPDATE_ERROR("AWF-0601","表单更新失败","任务号【{0}】，报错信息：【{1}】",(byte) 0),

    PROCESSSTARTSUCCESS_INFO("AWF-1001","流程【{0}({1})】发起成功，流程ID【{2}】发起人【{3}】","",(byte)1),
    FORMSAVESUCCESS_INFO("AWF-1002","表单保存成功【流程ID：{0}，任务ID：{1}】","",(byte) 1),
    STARTNODEAUTOFINISHSUCCESS_INFO("AWF-1003","完成流程发起节点自动处理【流程ID：{0}，任务ID：{1}】","",(byte)1),
    TASKFIX_SUCCESS_INFO("AWF-1004","任务【{0}】修复成功","",(byte)1),

    TASKDELEGATE_SAMEASSINEE_INFO("AWF-1005-1","流程任务【{0}】的处理人和目标代理人为同一人","",(byte)1),
    TASKDELEGATE_CHANGEASSIGN_INFO("AWF-1005-2","流程任务【{0}】已转交代理人【{1}】","",(byte)1),
    TASKDELEGATE_ADDCANDIDATE_INFO("AWF-1005-3","流程任务【{0}】已添加候选人【{1}】","",(byte)1),
    TASKDELEGATE_CANDIDATEEXIST_INFO("AWF-1005-4","流程任务【{0}】候选人【{1}】已存在","",(byte)1)



    ;
    private String infoCode; //格式如 AWF-XXXX 第一位是类型码 0：位出错信息 1：提示信息
    private String infoTitle;
    private String infoDescription;
    private byte infoType; //0--出错信息 1--提示信息

    AWFInfoEnum(String infoCode, String infoTitle, String infoDescription, byte infoType) {
        this.infoCode = infoCode;
        this.infoTitle = infoTitle;
        this.infoDescription = infoDescription;
        this.infoType = infoType;
    }

    @Override
    public String toString() {
        if(this.infoType == (byte)0) {
            return MessageFormat.format("[{0}]{1}：{2}",this.infoCode,this.infoTitle,this.infoDescription);
        }
        else if(this.infoType == (byte)1)
        {
            return this.infoTitle + (this.infoDescription.equals("")?"":(":"+this.infoDescription));
        }
        else
        {
            return "";
        }
    }
}
